package org.example;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class RedisMain {
    public static void main(String[] args) {
        JedisPool jedisPool = new JedisPool("tcp://127.0.0.1:8888");
        try (Jedis jedis = jedisPool.getResource()) {
            getAndSet(jedis);
        }
    }
    public static void getAndSet(Jedis jedis) {
        System.out.println("测试get和set");
        // 先刷新 Redis 库
        jedis.flushAll();
        // 添加key = "key"，value = "value"
        jedis.set("key","value");
        // 获取当前 key 所对应value
        String value = jedis.get("key");
        System.out.println("value：" + value);
    }
}
